package lschgcdev.net;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

import lschgcdev.apis.DataUser;

public class NetBasicIO extends DataUser<Object>{

	protected DataOutputStream out;
	protected DataInputStream in;
	
	public NetBasicIO() {}
	
	public NetBasicIO(String ID){
		super(ID);
	}
	
	protected void initIO(Socket socket) throws IOException{
		log.notice("Syncronizing with host...");
		out = new DataOutputStream(socket.getOutputStream());
		in = new DataInputStream(socket.getInputStream());	
	}
	
	public void send(String packet) throws IOException{
		log.notice("send -> "+packet);
		out.writeBytes(packet+'\n');
	}
	
	@SuppressWarnings("deprecation")
	public String recive() throws IOException{
		String packet = in.readLine();
		log.notice("recive <- "+packet);
		return packet;
	}
	
}
